<template>
	<view>
		<view class="box">
			<view class="cu-bar bg-white">
				<view class="action border-title">
					<text class="cuIcon-titles text-green"></text>
					<text class="text-xl text-bold">其他供应商价格</text>
				</view>
			</view>
			<view class="cu-list menu sm-border card-menu" v-for="(item, index) in supplierData" :key="index">
				<!-- 多行Item -->
				<view class="cu-item">
					<view class="content padding-tb-sm">
						<view class="text-dark text-sm">
							{{item.itemCode}}
						</view>
						<view class="text-dark text-sm">
							{{item.supplier}}
						</view>
						<view class="text-grey text-sm">
							{{item.applyTime}}
						</view>
						<view class="text-grey text-sm">
							申请人：{{item.applyer}}
						</view>
						<view class="text-dark text-lg">
							申请价格：{{item.price}}元
						</view>
					</view>
					<view class="action">
						<view class="cu-tag line-green" v-if="item.status == '0'">成功</view>
						<view class="cu-tag line-red" v-else>失败</view>

						<!-- {{item.status == "0" ? "成功" : '失败'}} -->
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getOtherPrice
	} from '@/api/approve'
	export default {
		data() {
			return {
				id: "",
				pageNum: 1,
				pageSize: 20,
				newPrice: '',
				itemCode: '',
				supplier: '',
				supplierData: [],
				totalSup: 0,
				loadingType: 'more',
			}
		},
		onLoad(option) {
			this.itemCode = option.itemCode
			this.newPrice = option.newPrice
			this.searchOther();
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1;
			this.supplierData.length = 0;
			this.searchOther('refresh');
		},
		// 加载更多
		onReachBottom() {
			if (this.loadingType === 'nomore' || this.supplierData.length === 0) return;
			this.page++;
			this.searchOther();
		},
		methods: {
			searchOther() {
				if (this.page == 1) {
					this.supplierData = []
				}
				const query = {
					itemCode: this.itemCode,
					supplier: this.supplier,
					pageNum: this.pagePrice,
					pageSize: this.limitPrice,
				};
				getOtherPrice(query).then((res) => {
					this.supplierData = res.item.records;
					this.loadingType = res.item.total > this.worksList.length ? 'more' : 'nomore';
				});
			},
			// searchOther() {
			// 	if (this.page == 1) {
			// 		this.supplierData = []
			// 	}
			// 	const query = {
			// 		itemCode: this.itemCode,
			// 		supplier: this.supplier,
			// 		pageNum: this.pageNum,
			// 		pageSize: this.pageSize,
			// 	};
			// 	getItemSupplier(query).then((res) => {
			// 		this.supplierData = res.item.records;
			// 		// this.totalSup = res.item.total;
			// 		this.loadingType = res.item.total > this.worksList.length ? 'more' : 'nomore';
			// 	});
			// },
		},

	}
</script>

<style scoped>
	.card-menu {
		margin-top: 20upx;
	}
</style>